package com.galina.notebook.dao.implementation;

import java.util.List;

import javax.ejb.Stateless;

import com.galina.notebook.dao.GenericDaoImpl;
import com.galina.notebook.dao.api.UserDaoRemote;
import com.galina.notebook.persistence.User;

@Stateless
public class UserDao extends GenericDaoImpl<User> implements UserDaoRemote {

	@Override
	public User find(Object id) {
		User usr=super.find(id);
		if (usr != null) usr.getParkingPlaces();
		return usr;
	}

	@SuppressWarnings("unchecked")
	public List<User> findUsersByLastName(String lastName) {
		return executeQuery("Select u from User u where u.lastName='" + lastName + "'");
	}

	@SuppressWarnings("unchecked")
	public List<User> findUsersByFirstName(String firstName) {
		return executeQuery("Select u from User u where u.firstName='" + firstName + "'");
	}

}
